package com.mouse.hxsj.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;
@Slf4j
public class BeanUtil {
    public static <T> T copyObject(Object o, T t) {
        try {
            BeanUtils.copyProperties(o, t);
            return t;
        } catch (Exception var3) {
            log.error(var3.getMessage(), var3);
            return null;
        }
    }

    public static <T> T copyObject(Object o, Class<T> cla) {
        try {
            T t = cla.newInstance();
            BeanUtils.copyProperties(o, t);
            return t;
        } catch (Exception var3) {
            log.error(var3.getMessage(), var3);
            return null;
        }
    }

    public static <T, S> List<T> copyList(List<S> list, Class<T> clazz) {
        return (List)list.stream().map((s) -> {
            Object t = null;

            try {
                t = clazz.newInstance();
                BeanUtils.copyProperties(s, t);
            } catch (Exception var4) {
                log.error(var4.getMessage(), var4);
            }

            return t;
        }).collect(Collectors.toList());
    }

}
